package com.pw.study.leetcode;

/**
 * @Author: linux_future
 * @since: 2022/4/18
 **/
public class Q1265 {

    public static void main(String[] args) {
        int[][] arr={{1,0},{1,1}};
        int[][] arr1={{1,0,0},{0,0,0},{1,0,1}};
        int ss = new Q1265().countServers(arr1);
        System.out.println(ss);
    }
    public int countServers(int[][] grid) {
        int rowlen=grid.length;
        int collen = grid[0].length;
        int[] count_row=new int[rowlen];
        int[] count_col=new int[collen];

        for (int i = 0; i < rowlen; ++i) {
            for (int j = 0; j < collen; ++j) {
                if (grid[i][j] == 1) {
                    ++count_row[i];
                    ++count_col[j];
                }
            }
        }
        //System.out.println(collen);
        int ans = 0;
        for (int i = 0; i < rowlen; ++i) {
            for (int j = 0; j < collen; ++j) {
                if (grid[i][j] == 1 && (count_row[i] > 1 || count_col[j] > 1)) {
                    System.out.println(count_row[i]+" : "+count_col[j]);
                    ++ans;
                }
            }
        }
        return ans;
    }
}
